dirName = '../Models/';

modelName = 'Cat';
Models = {
    'cat0.obj.allData.mat';
    'cat1.obj.allData.mat';
    'cat2.obj.allData.mat';
    'cat3.obj.allData.mat';
    'cat4.obj.allData.mat';
    'cat5.obj.allData.mat';
    'cat6.obj.allData.mat';
    'cat7.obj.allData.mat';
    'cat8.obj.allData.mat';
    'cat9.obj.allData.mat';
    'cat10.obj.allData.mat'
    };

%{
modelName = 'Centaur';
Models = {
    'centaur1.obj.allData.mat';
    'centaur2.obj.allData.mat';
    'centaur3.obj.allData.mat';
    'centaur4.obj.allData.mat';
    'centaur5.obj.allData.mat'
};
%}
    
%{
modelName = 'Dog';    
    Models = {
    };
%}

%{
modelName = 'Plate';    
    Models = {
    };
%}
    
n = size(Models, 1);
dirName = [dirName modelName '/'];

curDir = pwd;
cd(dirName);

% Load original undeformed source model
load(Models{1});
distanceMtr0 = distanceMtr;
cd(curDir);

% Those two following values we aim to compute actually
dataset.AveErr = 0.0;
dataset.MaxErr = 0.0;

% Load .mat files
for fi = 2 : n
    % load next target deformed mesh
    cd(dirName);
    load(Models{fi});
    cd(curDir);
    
    disp(['GeoErr -- Model #' int2str(fi) ' of ' int2str(n)]);
    [AveErr, MaxErr] = GeoErr(distanceMtr0, distanceMtr);
    
    sqrtMeshArea = sqrt(triMeshArea(vertices, triangles));
    dataset.AveErr = dataset.AveErr + AveErr / sqrtMeshArea;
    dataset.MaxErr = dataset.MaxErr + MaxErr / sqrtMeshArea;
end % for
dataset.AveErr = dataset.AveErr / n;
dataset.MaxErr = dataset.MaxErr / n;